<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use EloquentFilter\Filterable;

class FreightWay extends Model
{

    use Filterable;
    
	protected $appends = ['use_state', 'type_name', 'state_name'];

    protected $fillable = [
    	'machine_id','goods_id','capacity','stock','stock_warning','state','price','No', 'type', 'buying_price'
    ];
    public function getUseStateAttribute()
    {
    	return 1;
    }

    public function goods()
    {
    	return $this->belongsTo(Goods::class, 'goods_id','id');
    }

    public function machine()
    {
        return $this->belongsTo(Machine::class, 'machine_id', 'id');
    }


    public function getTypeNameAttribute()
    {
        return freight_type($this->type);
    }

    public function getStateNameAttribute()
    {
        return freight_state($this->state);
    }

}
